home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / EDWIN / MODELN.S < prev    next >
Encoding:
Text File  |  1993-06-15  |  5.1 KB  |  148 lines

  1. ;;;
  2. ;;;    Copyright (c) 1985 Massachusetts Institute of Technology
  3. ;;;
  4. ;;;    This material was developed by the Scheme project at the
  5. ;;;    Massachusetts Institute of Technology, Department of
  6. ;;;    Electrical Engineering and Computer Science.  Permission to
  7. ;;;    copy this software, to redistribute it, and to use it for any
  8. ;;;    purpose is granted, subject to the following restrictions and
  9. ;;;    understandings.
  10. ;;;
  11. ;;;    1. Any copy made of this software must include this copyright
  12. ;;;    notice in full.
  13. ;;;
  14. ;;;    2. Users of this software agree to make their best efforts (a)
  15. ;;;    to return to the MIT Scheme project any improvements or
  16. ;;;    extensions that they make, so that these may be included in
  17. ;;;    future releases; and (b) to inform MIT of noteworthy uses of
  18. ;;;    this software.
  19. ;;;
  20. ;;;    3.  All materials developed as a consequence of the use of
  21. ;;;    this software shall duly acknowledge such use, in accordance
  22. ;;;    with the usual standards of acknowledging credit in academic
  23. ;;;    research.
  24. ;;;
  25. ;;;    4. MIT has made no warrantee or representation that the
  26. ;;;    operation of this software will be error-free, and MIT is
  27. ;;;    under no obligation to provide any services, by way of
  28. ;;;    maintenance, update, or otherwise.
  29. ;;;
  30. ;;;    5.  In conjunction with products arising from the use of this
  31. ;;;    material, there shall be no use of the name of the
  32. ;;;    Massachusetts Institute of Technology nor of any adaptation
  33. ;;;    thereof in any advertising, promotional, or sales literature
  34. ;;;    without prior written consent from MIT in each case.
  35. ;;;
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;;
  38. ;;;     Modified by Texas Instruments Inc 8/15/85
  39. ;;;
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41.  
  42. ;;; modeline messages
  43. ;012345678901234567890123456789012345678901234567890123456789012345678901234567
  44. ;PCS Edwin VVVVVVVVVV Filename for the rest of the line
  45. ; cols 78 and 79 are reserved for the modified stars
  46. (begin
  47. (define-integrable name-position 4)
  48. (define-integrable version-position 11)
  49. (define-integrable version-length 6)
  50. (define-integrable mode-position 19)
  51. (define-integrable file-name-position 35)
  52. (define-integrable file-name-length 31)
  53. (define-integrable modified-position 0)
  54. (define-integrable buffer-position 17)
  55. )
  56.  
  57. (define reset-modeline-window #F)
  58. (define window-modeline-event! #F)
  59. (define update-modeline! #F)
  60.  
  61. (letrec
  62.  ((file-name #F)
  63.   (file-name-changed #F)
  64.   (version Edwin-Version)
  65.   (modified #F)
  66.   (modified-changed #F)
  67.   (mode-changed #F)
  68.   (mode-scheme? #T)
  69.   (position-cursor
  70.    (lambda (pos)
  71.      (%reify-port! modeline-screen screen:cursor-x pos)))
  72.   (string-upcase
  73.    (lambda (string)
  74.      (and string
  75.      (let loop ((string1 (make-string (string-length string) #\space))
  76.         (index 0) (end (string-length string)))
  77.       (if (< index end)
  78.           (begin
  79.                (string-set! string1 index
  80.                             (char-upcase (string-ref string index)))
  81.                (loop string1 (1+ index) end))
  82.               string1)))))
  83.   (write-modified (lambda ()
  84.             (set! modified-changed #F)
  85.             (position-cursor modified-position)
  86.             (princ (if modified "**" "  ") modeline-screen)))
  87.   (write-mode (lambda ()
  88.         (set! mode-changed #F)
  89.         (position-cursor mode-position)
  90.         (princ (if mode-scheme? "   [Scheme]    "
  91.                " [Fundamental] ")
  92.                modeline-screen)))
  93.   (write-file-name (lambda ()
  94.              (set! file-name-changed #F)
  95.              (clear-subscreen! modeline-screen
  96.                        file-name-position 0 0
  97.                        file-name-length)
  98.              (position-cursor file-name-position)
  99.              (if file-name (princ file-name modeline-screen)))))
  100.  
  101. (set! reset-modeline-window
  102.   (lambda ()
  103.     (let ((buffer (current-buffer)))
  104.       (set! modified (buffer-modified? buffer))
  105.       (set! modified-changed #T)
  106.       (set! file-name (string-upcase (buffer-pathname buffer)))
  107.       (set! file-name-changed #T)
  108.       (set! mode-scheme? *current-mode-scheme?*)
  109.       (set! mode-changed #T)
  110.       (%clear-window modeline-screen)
  111.       (%reify-port! modeline-screen screen:cursor-y 0)
  112.       (position-cursor name-position)
  113.       (princ "Edwin" modeline-screen)
  114.       (position-cursor version-position)
  115.       (princ version modeline-screen)
  116. ;;;      (position-cursor buffer-position)
  117. ;;;      (princ " Buffer : Main " modeline-screen)
  118.       (update-modeline!))))
  119.  
  120. (set! window-modeline-event!
  121.   (lambda (window event)
  122.     (let ((buffer (current-buffer)))
  123.       (cond ((eq? event 'buffer-modified)
  124.          (let ((buffer-modified (buffer-modified? buffer)))
  125.                (if (not (eq? buffer-modified modified))
  126.            (set! modified-changed #T))
  127.            (set! modified buffer-modified)))
  128.         ((eq? event 'buffer-pathname)
  129.          (set! file-name-changed #T)
  130.          (set! file-name (string-upcase (buffer-pathname buffer))))
  131.         ((eq? event 'mode-changed)
  132.          (set! mode-scheme? *current-mode-scheme?*)
  133.          (set! mode-changed #T))
  134.         (else #F)))))
  135.  
  136.  
  137. (set! update-modeline!
  138.   (lambda ()
  139.     (if modified-changed (write-modified))
  140.     (if file-name-changed (write-file-name))
  141.     (if mode-changed (write-mode)))))
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.